/**
 * @author casazaft
 */
Package("j2j.utils").Class("HashMap",{
	HashMap:function(){
		        
        var map = {};
        var length = 0;
        this.store = function(k, v){
            map[k] = v;
            length++;
        };
        this.retrieval = function(k){
            if (typeof k != "string") 
                throw Error("you must pass a String paramer to the" + this.getClass().getName() + ":retrieval()");
            return map[k];
        };
        this.remove = function(k){
            var reobj = map[k];
            if (reobj !== undefined) {
                delete map[k];
                length--;
            }
            return reobj;
        };
        this.clear = function(){
            map = {};
            length = 0;
        };
        this.each = function(fn, args){
            for (var k in map) {
                fn(map[k], args);
            }
        };
        this.getLength = function(){
            return length;
        };
        this.isEmpty = function(){
            return !length;
        };
        this.finalize = function(){
            for (var p in map) 
                delete map[p];
            map = null;
            this.Super.finalize();
        };
    }
});
